#!/bin/sh
# eotk (c) 2017 Alec Muffett
cd %PROJECT_DIR% || exit 1

lockfile=nginx.pid
if [ -s $lockfile ] ; then
    echo "$0: $lockfile exists, %PROJECT% may already be started, aborting!"
    exit 1
fi

%%IF %IS_SOFTMAP%
conffiles=`echo %PROJECT_DIR%/%TOR_WORKER_PREFIX%*.d/tor.conf`
%%ELSE
conffiles=%PROJECT_DIR%/tor.conf
%%ENDIF

for torconf in $conffiles ; do
    test -f $torconf && tor -f $torconf
done >%LOG_DIR%/tor-startup.log

sleep %SCRIPT_PAUSE%

nginxconf=%PROJECT_DIR%/nginx.conf
test -f $nginxconf && nginx -c $nginxconf

exit 0
